home *** CD-ROM | disk | FTP | other *** search
/ PC Pro 2003 March / DPPCPRO0303.ISO / Components / Microsoft ASP / _SETUP.1 / ASPWizard.jar / asp / netobjects / nfx / ui / EtchedTopBorder.class (.txt) < prev    next >
Encoding:
Java Class File  |  1998-11-20  |  2.2 KB  |  63 lines

  1. package asp.netobjects.nfx.ui;
  2.  
  3. import com.sun.java.swing.border.AbstractBorder;
  4. import java.awt.Color;
  5. import java.awt.Component;
  6. import java.awt.Graphics;
  7. import java.awt.Insets;
  8.  
  9. public class EtchedTopBorder extends AbstractBorder {
  10.    public static final int RAISED = 0;
  11.    public static final int LOWERED = 1;
  12.    protected int etchType;
  13.    protected Color highlight;
  14.    protected Color shadow;
  15.  
  16.    public EtchedTopBorder() {
  17.       this(1);
  18.    }
  19.  
  20.    public EtchedTopBorder(int etchType) {
  21.       this(etchType, (Color)null, (Color)null);
  22.    }
  23.  
  24.    public EtchedTopBorder(Color highlight, Color shadow) {
  25.       this(1, highlight, shadow);
  26.    }
  27.  
  28.    public EtchedTopBorder(int etchType, Color highlight, Color shadow) {
  29.       this.etchType = etchType;
  30.       this.highlight = highlight;
  31.       this.shadow = shadow;
  32.    }
  33.  
  34.    public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
  35.       g.translate(x, y);
  36.       g.setColor(this.etchType == 1 ? this.getShadowColor(c) : this.getHighlightColor(c));
  37.       g.drawLine(0, 0, width - 2, 0);
  38.       g.setColor(this.etchType == 1 ? this.getHighlightColor(c) : this.getShadowColor(c));
  39.       g.drawLine(1, 1, width - 3, 1);
  40.       g.translate(-x, -y);
  41.    }
  42.  
  43.    public Insets getBorderInsets(Component c) {
  44.       return new Insets(0, 2, 0, 0);
  45.    }
  46.  
  47.    public boolean isBorderOpaque() {
  48.       return true;
  49.    }
  50.  
  51.    public int getEtchType() {
  52.       return this.etchType;
  53.    }
  54.  
  55.    public Color getHighlightColor(Component c) {
  56.       return this.highlight != null ? this.highlight : c.getBackground().brighter();
  57.    }
  58.  
  59.    public Color getShadowColor(Component c) {
  60.       return this.shadow != null ? this.shadow : c.getBackground().darker();
  61.    }
  62. }
  63.